using System;
using System.Collections.Generic;
using System.Text;

namespace CodePlex.Resourceful.Json
{
    public abstract class JsonBase
    {


        protected static object ReadUnknown(JsonReader reader)
        {
            if (reader.TokenType == JsonToken.String)
            {
                string rt = reader.Value as string;
                reader.Read();  // string
                return rt;
            }
            else if (reader.TokenType == JsonToken.Integer)
            {
                long rt = (long)reader.Value;
                reader.Read();  // integer
                return rt;
            }
            else if (reader.TokenType == JsonToken.StartObject)
            {
                return new JsonObject(reader);
            }
            else if (reader.TokenType == JsonToken.StartArray)
            {
                return new JsonArray(reader);
            }
            else if (reader.TokenType == JsonToken.Null)
            {
                reader.Read();  // null
                return null;
            }
            else if (reader.TokenType == JsonToken.Boolean)
            {
                bool rt = (bool)reader.Value;
                reader.Read();  // boolean
                return rt;
            }

            throw new NotSupportedException(reader.TokenType.ToString());
        }




    }

}
